/*
 * @Author: 康家赫 13349195+kangjiahe666@user.noreply.gitee.com
 * @Date: 2024-05-20 11:41:07
 * @LastEditors: 康家赫 13349195+kangjiahe666@user.noreply.gitee.com
 * @LastEditTime: 2024-05-26 23:14:43
 * @FilePath: \MDK-ARMd:\Desktop\mcu_practice\imu_-eie_stm32experience_kjh\mcu_experience1\kjh_usingcode\modbus_use.c
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include "LED.h"
#include "modbusRTU.h"
#include "modbus_use.h"
#include "OLED.h"
#include "rocker.h"
#include "DS18B20.h"
#include "controler.h"
unsigned char uart1_rx_buf[2];
unsigned int UART1_overtime;
unsigned int UART1_offset;
unsigned char UART1_flag;
unsigned int ms_count, second_count;
void modbus_working()
{


    OLED_ShowString(0, 20, "             ", 16); // 修复显示bug
    if ((UART1_flag == 1) && (UART1_overtime > 100))//
    {
        ModbusRTU_Msg(1);
        UART1_offset = 0;
        UART1_overtime = 0;
        UART1_flag = 0;
    }
    AO_Buffer[1] = ADC_Read(ADC_CHANNEL_0);
    AO_Buffer[2] = ADC_Read(ADC_CHANNEL_1);
    AO_Buffer[3] = Read_Temperature();
    OLED_ShowNum(0, 48, AO_Buffer[1], 4, 16);
    OLED_ShowNum(60, 48, AO_Buffer[2], 4, 16);
    OLED_ShowNum(0, 0, AO_Buffer[3], 4, 16);
    OLED_Refresh();
    if (AO_Buffer[4])
    {
        turnup_ALL_led();
    }
    else
    {
        turndown_ALL_led();
    }

}
